package com.lansi.fb.truck.service;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.lansi.fb.truck.bean.Truck;
import com.lansi.fb.truck.mapper.TruckMapper;

@Service
public class TruckService implements ITruckService{
	@Resource
	private TruckMapper truckMapper;
	//添加车辆信息
	@Override
	public void register(Truck truck) {
		truckMapper.insertTruck(truck);
		
	}
	//根据id删除用户信息-可以批量删除
	@Override
	public void delTruck(Integer[] ids) {
		truckMapper.deleteTruck(ids);		
		
	}
	//单个删除用户，根据id
	@Override
	public void delTruckById(Integer id) {
		truckMapper.deleteById(id);
		
	}
	//2.车辆信息的修改
	@Override
	public void updateTruck(Integer id, String sn, String type, String brand, String driver, String drivercompany,
			String cardid, Date cardassign, Date cardrecyle, String recyle, String memo) {
		Truck truck = new Truck();
		truck.setId(id);
		truck.setSn(sn);
		truck.setType(type);
		truck.setBrand(brand);
		truck.setDriver(driver);
		truck.setDrivercompany(drivercompany);
		truck.setCardid(cardid);
		truck.setCardassign(cardassign);
		truck.setCardrecyle(cardrecyle);
		truck.setRecyle(recyle);
		truck.setMemo(memo);
		truckMapper.updateTruck(truck);
		
	}
	//根据id查询车辆信息
	@Override
	public Truck getTruckById(Integer id) {
		
		return truckMapper.selectTruckById(id);
	}
	//根据工号查询用户信息
	@Override
	public Truck getTruckByCardid(String cardid) {
		
		return truckMapper.selectTruckByCardid(cardid);
	}
	//根据车牌号查询车辆信息
	@Override
	public Truck getTruckBySn(String sn) {
	
		return truckMapper.selectTruckBySn(sn);
	}
	//根据用户选择的信息--查询出车辆的信息
	@Override
	public List<Truck> getTruck(String sn, String cardid, Integer offset, Integer count) {
	
		return truckMapper.selectTruck(sn, cardid, offset, count);
	}
	@Override
	public Integer getTruckcount(String sn ,String cardid) {
		
		return truckMapper.selectTruckcount(sn, cardid);
	}

}
